from tools import all_flow_ILAE_1434, all_flow_ILAE_1435, all_flow_ILAE_1438, all_flow_ILAE_1439
from global_parameter import ip, port, username, DB_NAME

channel_2v2_scene1 = [
    "1, 6, 1, 1, '1', 5, '1', 2, '2023-07-29 17:00:55', NULL, '', 1, ''",
    "2, 6, 2, 2, '2', 5, '1', 2, '2023-07-29 17:00:55', NULL, '', 1, ''",
    "3, 6, 3, 100, '100', 4, '1', 2, '2023-07-29 17:00:55', NULL, '', 1, ''",
    "4, 6, 4, 101, '101', 4, '1', 2, '2023-07-29 17:00:55', NULL, '', 1, ''"]

addr_2v2_scene1 = [
    "1, 1, '000000001001'",
    "2, 2, '000000001002'",
    "3, 100, '000000001100'",
    "4, 101, '000000001101'"]

current_1A_sql_config = [
    "TRUNCATE au_board_information;",
    "TRUNCATE au_channel_sort;",
    "TRUNCATE au_collect_board_config;",
    "TRUNCATE au_main_board_config;",
    "INSERT INTO `au_board_information` VALUES (3, 6, '电流采集板卡', '02', '02', 'CVT-CT-DSP_1.0.2', 'CVT-CT-DSP_1.2.8', '2023-08-07 15:45:58', '2023-08-07 15:45:58', 0, NULL, NULL, 1, '1');",
    "INSERT INTO `au_channel_sort` VALUES (1, '02', '02', 6, '1', 'A', '4001', 1, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (2, '02', '02', 6, '1', 'B', '4002', 2, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (3, '02', '02', 6, '1', 'C', '4003', 3, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (4, '02', '02', 6, '2', 'A', '4011', 4, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (5, '02', '02', 6, '2', 'B', '4012', 5, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (6, '02', '02', 6, '2', 'C', '4013', 6, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (7, '02', '02', 6, '3', 'A', '4021', 7, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (8, '02', '02', 6, '3', 'B', '4022', 8, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (9, '02', '02', 6, '3', 'C', '4023', 9, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (10, '02', '02', 6, '4', 'A', '4031', 10, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (11, '02', '02', 6, '4', 'B', '4032', 11, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (12, '02', '02', 6, '4', 'C', '4033', 12, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (13, '02', '02', 6, '5', 'A', '4041', 13, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (14, '02', '02', 6, '5', 'B', '4042', 14, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (15, '02', '02', 6, '5', 'C', '4043', 15, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_collect_board_config` VALUES (1, 1, '02', '02', 6, 16, 'CVT-CT-DSP_1.0.2', 16, 'CVT-CT-DSP_1.2.8', '', 8, '22092101', '2023-08-07 15:45:58', 1, '1', NULL, NULL);",
    "INSERT INTO `au_main_board_config` VALUES (1, '02', 7, '1.0.0.1', 5, '1.5.1', '', 8, '22120901', '2023-08-07 15:45:58', 1);"
]

no_group_2v2 = [
    "1, 1, 5, 1",
    "1, 2, 5, 1",
    "1, 100, 4, 1",
    "1, 101, 4, 1"]

# 通用算法
algo_scene = [
    "4, '1', '1', '1,3', '0', '', '0', NULL, '2023-04-14 11:44:50', NULL, NULL, NULL, NULL, NULL, 7, 14, 7, 14, '0', '0', '1'"]

"""
330kV电压等级对应的字典键值(8)  330kV电压等级线路数  330kV电压等级同源标志(True  False)  330kV电压等级分列标志(True  False)  330kV电压等级停电标志(True  False) 
220kV电压等级对应的字典键值(5)  220kV电压等级线路数  220kV电压等级同源标志(True  False)  220kV电压等级分列标志(True  False)  220kV电压等级停电标志(True  False) 
110kV电压等级对应的字典键值(4)  110kV电压等级线路数  110kV电压等级同源标志(True  False)  110kV电压等级分列标志(True  False)  110kV电压等级停电标志(True  False) 
10kV 电压等级对应的字典键值(3)  10kV 电压等级线路数  10kV 电压等级同源标志(True  False)  10kV 电压等级分列标志(True  False)  10kV 电压等级停电标志(True  False) 
"""
v_arg_2v2_gao_bing_di_bing = [8, 0, False, False, False,
                              5, 2, False, False, False,
                              4, 2, False, False, False,
                              3, 0, False, False, False]

# ILAE-1434 电流数据丢失_某时刻缺失数据触发
all_flow_ILAE_1434(ip, DB_NAME, v_arg_2v2_gao_bing_di_bing, "ILAE-1434", current_1A_sql_config, channel_2v2_scene1,
                   addr_2v2_scene1, no_group_2v2, algo_scene,
                   [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150], time_data=[-25, 70])

# ILAE-1435 电流数据丢失_关闭采集单元触发
all_flow_ILAE_1435(ip, DB_NAME, v_arg_2v2_gao_bing_di_bing, "ILAE-1435", current_1A_sql_config, channel_2v2_scene1,
                   addr_2v2_scene1, no_group_2v2, algo_scene,
                   [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150], time_data=[-25, 70])

# # ILAE-1436 电流数据丢失_X86掉电3分钟触发
# # # todo 需要控制断电，暂时无法模拟
#
# # ILAE-1437 电流数据丢失_恢复_数据恢复
# # # todo 需要重新打开采集单元，单纯在数据库中打开无效，需要连接采集单元，无法单独模拟
#
# # ILAE-1438 电流数据丢失_恢复_线路删除
# # # todo 用例步骤缺少，待补充
# all_flow_ILAE_1438(ip, DB_NAME, v_arg_2v2_gao_bing_di_bing, "ILAE-1438", current_1A_sql_config, channel_2v2_scene1, addr_2v2_scene1,
#                    no_group_2v2, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 70])

# ILAE-1439 电流数据重复_某分钟存在通道1的2条采集数据触发
all_flow_ILAE_1439(ip, DB_NAME, v_arg_2v2_gao_bing_di_bing, "ILAE-1439", current_1A_sql_config, channel_2v2_scene1,
                   addr_2v2_scene1, no_group_2v2, algo_scene,
                   [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150], time_data=[-25, 70])
